Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Add a unit test for config_controller.go #438

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

sophieliu15
Copy link
Contributor

@sophieliu15 sophieliu15 commented Feb 19, 2020

Add a unit test for config_controller.go to test the case that when a new type is added to HNCConfiguration singleton, the corresponding object reconciler can be created correctly.

This PR also does the following refactoring:

  • Moves shared helper functions from each controller test files to a common file: test_helpers_test.go
  • Switches the object type in object_controller_test.go from Secret to Role because:
    • The behaviors that are tested in the object_controller_test.go are irrelevant to the object type or the creation of a new object reconciler.
    • Since the test suite creates the object reconciler for Role by default, object_controller_test.go can use the existing Role object reconciler for the tests
      instead of creating a new object reconciler.
    • The tests inside controllers_test package share the same test environment, which means if the test in one Describe container adds a type to
      HNCConfiguration singleton, the corresponding object reconciler for that type will be created and will still be there when running subsequent Describe
      containers in the package. Until we find a way to "cleanup" object reconcilers, it is better to only create new object reconcilers when necessary.

Design doc: http://bit.ly/hnc-type-configuration
Issue: #411

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 19, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @sophieliu15. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 19, 2020
@k8s-ci-robot k8s-ci-robot requested a review from srampal February 19, 2020 17:10
@sophieliu15 sophieliu15 force-pushed the hnc_config_test branch 3 times, most recently from 0e22293 to a76d711 Compare February 20, 2020 02:28
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 20, 2020
@sophieliu15 sophieliu15 force-pushed the hnc_config_test branch 6 times, most recently from 1bd9434 to 82f9ab5 Compare February 20, 2020 03:33
@adrianludwin
Copy link
Contributor

/ok-to-test

lgtm after a few nits. @rjbez17 , wdyt?

/assign @rjbez17

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 20, 2020
Add a unit test for config_controller.go to test the case that when a new type is added to HNCConfiguration singleton, the corresponding object reconciler can be created correctly.

This PR also does the following refactoring:
   -  Moves shared helper functions from each controller test files to a common file: test_helpers_test.go
   -  Switches the object type in object_controller_test.go from Secret to Role because:
       -  The behaviors that are tested in the object_controller_test.go are irrelevant to the object type or the creation of a new object reconciler.
       -  Since the test suite creates the object reconciler for Role by default, object_controller_test.go can use the existing Role object reconciler
       for the tests instead of creating a new object reconciler.
       -  The tests inside controllers_test package share the same test environment, which means if the test in one Describe container adds a type to
       HNCConfiguration singleton, the corresponding object reconciler for that type will be created and will still be there when running subsequent Describe
       containers in the package. Until we find a way to "cleanup" object reconcilers, it is better to only create new object reconcilers when necessary.

Design doc: http://bit.ly/hnc-type-configuration
Issue: kubernetes-retired#411
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve
/hold

@rjbez17 feel free to remove the hold if you're happy (or don't feel like reviewing again)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 20, 2020
@k8s-ci-robot k8s-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 20, 2020
@rjbez17
Copy link

rjbez17 commented Feb 20, 2020

/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 20, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, rjbez17, sophieliu15

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [adrianludwin,rjbez17]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants